package com.example.common;

/**
 * Created by Tony Yao on 2017/7/19.
 */

public class AssertThrowUtil {//验证类
    public static String assertNotBlank(String message,String target){
        if(target==null||target.trim().length()==0){
            throw new ThisSystemException(message);
        }
        return target;
    }

    public static String $(String message,String target){
        return  assertNotBlank(message,target);
    }

    public static void assertNotNull(String message,Object o){
        if(o==null){
            throw new ThisSystemException(message);
        }
    }

    public static void assertNull(String message,Object o){
        if(o!=null){
            throw new ThisSystemException(message);
        }
    }

    public static void assertEquals(String message,Object a,Object b){
        if(a==null?a!=b:!a.equals(b)){
            throw new ThisSystemException(message);
        }
    }

    public static void assertNotEquals(String message,Object a,Object b){
        if(a==null?a==b:a.equals(b)){
            throw new ThisSystemException(message);
        }
    }

    public static void assertTrue(String message,Object a){
        if(!(Boolean)a){
            throw new ThisSystemException(message);
        }
    }

}
